package com.ssy.lingxi.member.merchant.api.model.constant;

import java.util.Arrays;

/**
 * 会员入库、变更流程枚举
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-14
 */
public enum MemberProcessTypeEnum {
    /**
     * 平台会员审核流程 - 0
     */
    PLATFORM_VALIDATION(0, "会员注册流程"),

    /**
     * 会员入库流程 - 1
     */
    MEMBER_DEPOSITORY(1, "会员入库流程"),

    /**
     * 会员变更流程 - 2
     */
    MEMBER_MODIFICATION(2, "会员变更流程"),

    /**
     * 未定义（用于数据初始化）
     */
    UNKNOWN(99, "未定义");

    MemberProcessTypeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private final Integer code;
    private final String msg;

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static String getMsg(Integer code) {
        MemberProcessTypeEnum processTypeEnum = Arrays.stream(MemberProcessTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return processTypeEnum == null ? "未知" : processTypeEnum.getMsg();
    }

    public static MemberProcessTypeEnum parse(Integer code) {
        return Arrays.stream(MemberProcessTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(UNKNOWN);
    }
}
